import java.util.Map;
import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] = in.next();
        }
        System.out.println(longestCommonPrefix(strings));
    }
    public static String longestCommonPrefix(String[] strs) {
        if(strs.length==0){
            return "";
        }
        String flag = strs[0];
        for (int i = 1; i < strs.length; i++) {
            //不断和后面一个单词进行匹配
            flag = getResult(flag,strs[i]);
        }
        return flag;
    }
    public static String getResult(String str1,String str2){
        int result = 0;//用来记录相同字母的位置(从0到result)
        int length = Math.min(str1.length(),str2.length());//只需要遍历少的那一个的字符串长度
        for (int i = 0; i < length; i++) {
            if(str1.charAt(i)!=str2.charAt(i)){
                break;
            }
            result++;
        }
        return str1.substring(0,result);
    }
}
